<template>
	<view class="index-list animate__animated animate__fadeInLeft fast">
		<view class="index-list1">
			<view>
				<image :src="item.userpic" mode="widthFix" lazy-load></image>
				{{item.username}}
			</view>
			<view v-show="!item.isguanzhu" @tap="guanzhu">
				<view class="iconfont icon-zengjia"></view>关注
			</view>
		</view>
		<view class="index-list2" @tap="opendetail">{{item.title}}</view>
		<view class="index-list3 u-f-ajc" @tap="opendetail">
			<!-- 图片 -->
			<image :src="item.titlepic" mode="widthFix" lazy-load></image>
			<!-- 视频 -->
			<template v-if="item.type=='video'">
				<view class="index-list-play iconfont icon-iconset0481"></view>
				<view class="index-list-playinfo">
					{{item.playnum}}次播放 {{item.long}}
				</view>
			</template>
		</view>
		<view class="index-list4">
			<view>
				<view :class="{'active':(item.infonum.index==1)}"
				@tap="caozuo('ding')">
					<view class="iconfont icon-xiaolian1"></view>
					{{item.infonum.dingnum}}
				</view>
				<view :class="{'active':(item.infonum.index==2)}"
				@tap="caozuo('cai')">
					<view class="iconfont icon-kulian"></view>
					{{item.infonum.cainum}}
				</view>
			</view>
			<view>
				<view>
					<view class="iconfont icon-pinglun"></view>
					{{item.infonum.dingnum}}
				</view>
				<view>
					<view class="iconfont icon-zhuanfa"></view>
					{{item.sharenum}}
				</view>
			</view>
		</view>
	</view>	
</template>

<script>
	export default {
		props:{
			item:Object,
			index:Number
		},
		methods:{
			//关注
			guanzhu(){
				this.item.isguanzhu=true
				uni.showToast({
					title:'关注成功'
				});
			},
			//顶踩
			caozuo(type){
				switch(type){
					case "ding":
					if(this.item.infonum.index==1){return;}
					this.item.infonum.dingnum++;
					if(this.item.infonum.index==2){
						this.item.infonum.cainum--
					}
					this.item.infonum.index = 1
					    break;
					case "cai":
					if(this.item.infonum.index==2){return;}
					this.item.infonum.cainum++;
					if(this.item.infonum.index==1){
						this.item.infonum.dingnum--
					}
					this.item.infonum.index=2
					    break;
				}
			},
			// 进入详情页
			opendetail(){
				uni.navigateTo({
					url:'../../pages/detail/detail?detailData='+JSON.stringify(this.item),
				})
			}
		}
	}
</script>

<style scoped>
	.u-f,.u-f-ac,.u-f-ajc {
		display: flex;
	}
	.u-f-ac,.u-f-ajc { 
		align-items: center;
	}
	.u-f-ajc {
		justify-content: center;
	}
	.index-list {
		padding: 20upx;
		border-bottom: 1upx solid #EEEEEE;
	}
	.index-list1{
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.index-list1>view:first-child {
		display: flex;
		align-items: center;
		color: #999999;
	}
	.index-list1>view:first-child image {
		width: 90upx;
		height: 90upx;
		border-radius: 100%;
		margin-right: 10upx;
	}
	.index-list1>view:last-child {
		display: flex;
		align-items: center;
		background: #F4F4F4;
		border-radius: 5upx;
		padding: 0 10upx;
	}
	.index-list2{
		padding-top: 15upx;
		font-size: 32upx
	}
	.index-list3{
		position: relative;
		padding-top: 15upx;
	}
	.index-list3>image {
		width: 100%;
		border-radius: 20upx;
	}
	.index-list4{
		padding: 15upx 0;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.index-list4 view {
		color: #999999;
	}
	.index-list4>view:first-child {
		display: flex;
		align-items: center;
	}
	.index-list4>view:last-child {
		display: flex;
		align-items: center;
	}
	.index-list4>view>view {
		display: flex;
		align-items: center;
	}
	.index-list4>view>view>view {
		margin-right: 15upx;
	}
	.index-list4>view>view:first-child {
		margin-right: 10upx;
	}
	.index-list-play {
		position: absolute;
		font-size: 140upx;
		color: #FFFFFF;
	}
	.index-list-playinfo {
		position: absolute;
		background: rgba(51,51,51,0.72);
		color: #FFFFFF;
		bottom: 8upx;
		right: 8rpx;
		border-radius: 40upx;
		font-size: 22rpx;
		padding: 0 12upx;
	}
	.index-list4 .active,.index-list4 .active>view {
		color:#C5F61C;
	}
</style>
